package com.sinosoft.hydra.um.domain.permission;

import org.hibernate.annotations.GenericGenerator;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.persistence.*;

/**
 * 日志基础信息
 * @author Administrator
 *
 */
@Entity
@Table(name="logging_event")
public class SysLogInfo implements Serializable{
	private static final long serialVersionUID = 1L;
	private String id;
	private Date createDate;//发生日期
	private String msg;//消息
	private String recorder;//记录器
	private String level;//日志级别
	private String file;//文件
	private String entityClass;//类
	private String method;//方法
	private String line;//调用的代码行
    private String threadName;
    private String userName;
    private String ipAddress;

    @Id
    @Column(name = "event_id")
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}		
	
	/**
	 * 发生日期
	 * @return long
	 */
	@Column(name="timestmp")
	public Date getCreateDate() {
		return createDate;
	}
	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
	/**
	 * 消息
	 * @return String
	 */
	@Column(name="formatted_message")
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	/**
	 * 记录器
	 * @return String
	 */
	@Column(name="logger_name")
	public String getRecorder() {
		return recorder;
	}
	public void setRecorder(String recorder) {
		this.recorder = recorder;
	}
	/**
	 * 日志级别
	 * @return String
	 */
	@Column(name="level_string")
	public String getLevel() {
		return level;
	}
	public void setLevel(String level) {
		this.level = level;
	}
	/**
	 * 文件
	 * @return String
	 */
	@Column(name="caller_filename")
	public String getFile() {
		return file;
	}
	public void setFile(String file) {
		this.file = file;
	}
	/**
	 * 类
	 * @return String
	 */
	@Column(name="caller_class")
	public String getEntityClass() {
		return entityClass;
	}
	public void setEntityClass(String entityClass) {
		this.entityClass = entityClass;
	}
	/**
	 * 方法
	 * @return String
	 */
	@Column(name="caller_method")
	public String getMethod() {
		return method;
	}
	public void setMethod(String method) {
		this.method = method;
	}

    @Column(name="thread_name")
    public String getThreadName() {
        return threadName;
    }

    public void setThreadName(String threadName) {
        this.threadName = threadName;
    }

    @Column(name="user_name")
    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Column(name="ip_address")
    public String getIpAddress() {
        return ipAddress;
    }

    public void setIpAddress(String ipAddress) {
        this.ipAddress = ipAddress;
    }

    /**
	 * 调用的代码行
	 * @return String
	 */
	@Column(name="caller_line")
	public String getLine() {
		return line;
	}
	public void setLine(String line) {
		this.line = line;
	}

	public String toString() {
		SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		return format.format(createDate)+ " | " + id + " | " + userName +" | " + ipAddress +" | "
				+ msg + " | " + recorder + " | " + level
				+ " | " + file + " | " + entityClass
				+ " | " + method + " | " + line+" | \r\n";
	}
}
